﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Simple.Services;
using Simple.Services.System.QHSEViolationCategory.Models;

namespace Simple.WebApi.Controllers.System;

/// <summary>
/// 违章性质分析
/// </summary>
[Route("QHSEViolationTypeAnalysis/[action]")]
[ApiController]
public class QHSEViolationTypeAnalysisController : ControllerBase
{
    private readonly ViolationTypeAnalysisService _violationTypeAnalysisService;

    public QHSEViolationTypeAnalysisController(ViolationTypeAnalysisService violationTypeAnalysisService)
    {
        _violationTypeAnalysisService = violationTypeAnalysisService;
    }
    /// <summary>
    /// 违章性质分析--违章性质
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_xz_analysis")]
    public async Task<AppResult> ViolationTypeAnalysis([FromBody] ViolationAnalysisInput input)
    {
        var res = await _violationTypeAnalysisService.ViolationTypeAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章性质分析--通用/专业
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_xz_analysis")]
    public async Task<AppResult> ViolationTypeCategoryAnalysis([FromBody]ViolationAnalysisInput input)
    {
        var res = await _violationTypeAnalysisService.ViolationTypeCategoryAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章性质分析--各专业违章性质
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_xz_analysis")]
    public async Task<AppResult> WorkSpecialityAnalysis([FromBody] ViolationAnalysisInput input)
    {
        var res = await _violationTypeAnalysisService.WorkSpecialityAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章性质分析--各工龄段违章性质
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_xz_analysis")]
    public async Task<AppResult> WorkYearsAnalysis([FromBody] ViolationAnalysisInput input)
    {
        var res = await _violationTypeAnalysisService.WorkYearsAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章性质分析--各年龄段违章性质
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_xz_analysis")]
    public async Task<AppResult> AgeAnalysis([FromBody] ViolationAnalysisInput input)
    {
        var res = await _violationTypeAnalysisService.AgeAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章性质分析--用工性质违章性质
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_xz_analysis")]
    public async Task<AppResult> EmployeeTypeAnalysis([FromBody] ViolationAnalysisInput input)
    {
        var res = await _violationTypeAnalysisService.EmployeeTypeAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章性质分析--人的不安全行为/管理缺陷
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_xz_analysis")]
    public async Task<AppResult> UnsafeFactorsAnalysis([FromBody] ViolationAnalysisInput input)
    {
        var res = await _violationTypeAnalysisService.ViolationCategoryAnalysisAsync(input,"不安全因素");
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章性质分析--人的不安全行为
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_xz_analysis")]
    public async Task<AppResult> UnsafeBehaviorAnalysis([FromBody] ViolationAnalysisInput input)
    {
        var res = await _violationTypeAnalysisService.ViolationCategoryAnalysisAsync(input, "人的不安全行为");
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章性质分析--管理缺陷
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_xz_analysis")]
    public async Task<AppResult> ManagementDeficienciesAnalysis([FromBody] ViolationAnalysisInput input)
    {
        var res = await _violationTypeAnalysisService.ViolationCategoryAnalysisAsync(input, "管理缺陷");
        return AppResult.Status200OK(data: res);
    }
}
